home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / dsniff / decode_aim.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-16  |  1011 b   |  57 lines

  1. /*
  2.   decode_aim.c
  3.  
  4.   AOL Instant Messenger.
  5.   
  6.   Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  7.  
  8.   $Id: decode_aim.c,v 1.1 2000/05/16 17:31:14 dugsong Exp $
  9. */
  10.  
  11. #include <sys/types.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include "hex.h"
  15. #include "decode.h"
  16.  
  17. /* XXX - need to investigate AOL's FLAP, SNAC layers more... */
  18. int
  19. decode_aim(u_char *buf, int len)
  20. {
  21.     static char *aim_xor = "Tic/Toc";
  22.     int i, j;
  23.     char *p;
  24.     
  25.     Buf[0] = '\0';
  26.     
  27.     if ((p = bufbuf(buf, len, "toc_signon ", 11)) == NULL)
  28.         return (0);
  29.     
  30.     i = 0;
  31.     for (p = strtok(p, " "); p != NULL; p = strtok(NULL, " ")) {
  32.         strlcat(Buf, p, sizeof(Buf));
  33.         strlcat(Buf, " ", sizeof(Buf));
  34.         if (++i > 4) break;
  35.     }
  36.     if (p == NULL)
  37.         return (0);
  38.     
  39.     strlcat(Buf, "[", sizeof(Buf));
  40.     
  41.     j = hex_decode(p + 2, p, strlen(p));
  42.     for (i = 0; i < j; i++)
  43.         p[i] = p[i] ^ aim_xor[i % 7];
  44.     p[j] = '\0';
  45.     strlcat(Buf, p, sizeof(Buf));
  46.     
  47.     strlcat(Buf, "]\n", sizeof(Buf));
  48.     
  49.     len = strlen(Buf);
  50.     
  51.     if (!is_ascii_string(Buf, len))
  52.         return (0);
  53.     
  54.     return (len);
  55. }
  56.  
  57.